var config = require('../../config.json');
var logger = require('log4js').getLogger();
var request = require("request");
var sdp_server = config.sdp_server.host + ":" + config.sdp_server.port;

exports.removeCert = function (req, res, next) {
    cert_id = req.params.cert_id;
    request(
        {
            url: sdp_server + '/api/project/removeCert',
            method: "DELETE",
            json: true,
            body: body
        }
        , function (err, response, data) {
            if (err) {
                return res.format_json(null, 500, "更新依赖失败:" + err);
            }
            res.format_json(data);
        });
};

exports.addCert = function (req, res, next) {
    var cert_info = req.body;
    var project_id = req.params.project_id;
    request( {
        url: sdp_server + "/api/cert/"+ project_id,
        method: "POST",
        json: true,
        body: cert_info
    }, function (err, response, data) {
        if (err || data.code == '500') {
            logger.error(err);
            return res.format_json(null,500,err);
        } else {
            res.format_json({success:true,cert:data.data});
        }
    });
};